package com.yunxi.controller.eai;

import com.yunxi.baseDataToHub.pojo.TSP.VehicleLocationVO;
import com.yunxi.baseDataToHub.pojo.sap.PartnerInfoVO;
import com.yunxi.baseDataToHub.service.tsp.TspDubboService;
import com.yunxi.bizToHub.pojo.*;
import com.yunxi.bizToHub.service.VehicleChargingPileDubboService;
import com.yunxi.bizToHub.service.VehicleStockManageDubboService;
import com.yunxi.core.web.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2019/6/1.
 */
@RestController
@RequestMapping("/esb/api")
@Api(tags = "esb:manage", description = "接收esb信息")
public class VehicleStockManageController {

    @Autowired
    private VehicleStockManageDubboService vehicleStockManageDubboServiceImpl;
    @Autowired
    private VehicleChargingPileDubboService vehicleChargingPileDubboServiceImpl;
    @Autowired
    private TspDubboService tspDubboServiceImpl;


    /**
     * 向SAP发送整车交货过账数据
     * PMS -> SAP
     */
    @PostMapping("/vehicleDeliveryOrderPms2Sap")
    @ApiOperation(value = "向SAP发送整车交货过账数据")
    public Object vehicleDeliveryOrderPms2Sap(@RequestBody VehicleDeliveryOrderPostingVO order) throws Exception {

        Object object=vehicleStockManageDubboServiceImpl.vehicleDeliveryOrderPostingPms2Sap(order);
        return object;
    }
    /**
     * 整车VDC入库
     * PMS -> SAP
     */
    @PostMapping("/vehicleInboundPms2Sap")
    @ApiOperation(value = "整车VDC入库")
    public Object vehicleInboundPms2Sap(@RequestBody VehicleInboundVdcVO order) throws Exception {

        Object object=vehicleStockManageDubboServiceImpl.vehicleInboundPms2Sap(order);
        return object;
    }

    /**
     整车库存同步
     * 接口显示是移库单
     */
    @PostMapping("/vehicleStockShiftPms2Sap")
    @ApiOperation(value = " 整车库存同步")
    public Object vehicleStockShiftPms2Sap(@RequestBody VehicleStockShiftVO order) throws Exception {

        ApiResult object=vehicleStockManageDubboServiceImpl.vehicleStockShiftPms2Sap(order);
        return object;
    }

    /**
     * 扫码出库信号同步(厂库)合并
     * 车辆出入库信息同步至TSP
     * pms->tsp
     */
    @PostMapping("/vehicleStockStatusPms2Tsp")
    @ApiOperation(value = "扫码出库信号同步(厂库)合并")
    public Object vehicleStockStatusPms2Tsp(@RequestBody VehicleStockStatusVO order) throws Exception {

        Object object=vehicleStockManageDubboServiceImpl.vehicleStockStatusPms2Tsp(order);
        return object;
    }

    /**
     * 车辆实销信息
     * pms->tsp
     */
    @PostMapping("/stockStatusPms2Tsp")
    @ApiOperation(value = "车辆实销信息")
    public Object stockStatusPms2Tsp(@RequestBody CustomerSalesInfoVO order) throws Exception {
        Object object=vehicleStockManageDubboServiceImpl.vehicleCustomerSalesInfoPms2Tsp(order);
        return object;
    }


    /**
     * 发送派单数据
     * @param order
     * @return
     */
    @PostMapping("/vehicleChargingPileOrderPms2Aieg")
    @ApiOperation(value = "发送派单数据")
    public ApiResult vehicleChargingPileOrderPms2Aieg(@RequestBody ChargingPileOrderVO order){
        ApiResult apiResult = vehicleChargingPileDubboServiceImpl.vehicleChargingPileOrderPms2Aieg(order);
        return apiResult;
    }


    /**
     * 发送充电桩退订
     * @param order
     * @return
     */
    @PostMapping("/vehicleReturnPilePms2Aieg")
    @ApiOperation(value = "发送充电桩退订")
    public ApiResult vehicleReturnPilePms2Aieg(@RequestBody ReturnPileVO order){
        ApiResult apiResult = vehicleChargingPileDubboServiceImpl.vehicleReturnPilePms2Aieg(order);
        return apiResult;
    }


    /**
     * 车辆过户
     * pms->tsp
     */
    @PostMapping("/vehicleAssignedInfoPms2Tsp")
    @ApiOperation(value = "车辆过户")
    public Object vehicleAssignedInfoPms2Tsp(@RequestBody AssignedInfoVO order) throws Exception {
        Object object=vehicleStockManageDubboServiceImpl.vehicleAssignedInfoPms2Tsp(order);
        return object;
    }

    @PostMapping("/findVehicleLocationPms2Tsp")
    @ApiOperation(value = "获取TSP车辆位置")
    public Object findVehicleLocationPms2Tsp(@RequestBody VehicleLocationVO order) throws Exception {
        Object object=tspDubboServiceImpl.findVehicleLocationPms2Tsp(order);
        return object;
    }
}
